package com.hqq.exercise.array;

import java.util.LinkedList;
import java.util.Scanner;

/**
 * MidNum 合并数组中位数
 * Created by heqianqian on 2017/9/21.
 */
public class MidNum {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] array = new int[N];
        for (int i = 0; i < N; i++) {
            array[i] = scanner.nextInt();
        }
        int M = scanner.nextInt();
        int[] brray = new int[M];
        for (int i = 0; i < M; i++) {
            brray[i] = scanner.nextInt();
        }
        double v = findMidNumber(array, brray);
        if (isInteger(v)) {
            System.out.println((int) v);
        } else {
            System.out.println(v);
        }
    }

    private static double findMidNumber(int[] array, int[] brray) {
        if (array == null || brray == null) {
            return -1;
        }
        if (array.length + brray.length == 0) {
            return -1;
        }
        if (brray.length == 0) {
            return findMidNumber(brray, array);
        }
        int m = array.length;
        int n = brray.length;
        int len = m + n;
        int left = -1, right = -1, aStart = 0, bStart = 0;
        for (int i = 0; i <= len / 2; i++) {
            left = right;
            if (aStart < m && (bStart >= n || array[aStart] < brray[bStart])) {
                right = array[aStart++];
            } else {
                right = brray[bStart++];
            }
        }
        if ((len & 1) == 0) {
            return (left + right) / 2.0;
        } else {
            return right;
        }
    }

    private static boolean isInteger(double d) {
        int a = (int) d;
        return a == d;
    }
}
